Skip to content

Support pl.Expr.dt.century - #23153

Merged
rapids-bot[bot] merged 1 commit into
NVIDIA:mainfrom
mroeschke:cudf_polars/enh/dt_century
Jul 8, 2026
Merged

Support pl.Expr.dt.century#23153
rapids-bot[bot] merged 1 commit into
NVIDIA:mainfrom
mroeschke:cudf_polars/enh/dt_century

Conversation

@mroeschke

Copy link
Copy Markdown
Contributor

Description

xref #23151

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@mroeschke mroeschke self-assigned this Jul 7, 2026
@mroeschke
mroeschke requested a review from a team as a code owner July 7, 2026 22:30
@mroeschke
mroeschke requested a review from rjzamora July 7, 2026 22:30
@mroeschke mroeschke added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Jul 7, 2026
@github-actions github-actions Bot added Python Affects Python cuDF API. cudf-polars Issues specific to cudf-polars labels Jul 7, 2026
@GPUtester GPUtester moved this to In Progress in cuDF Python Jul 7, 2026
@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 53512a57-2c3a-4f18-a11d-6ffa2e0ea3fe

📥 Commits

Reviewing files that changed from the base of the PR and between 4cce29f and 4f0a581.

📒 Files selected for processing (2)
  • python/cudf_polars/cudf_polars/dsl/expressions/datetime.py
  • python/cudf_polars/tests/expressions/test_datetime_basic.py

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added support for extracting the century from date and datetime values.
    • Century calculations now handle null values and a wider range of date inputs, including edge-case years.

Walkthrough

Adds explicit support for computing the Century temporal component in TemporalFunction, introducing a divisor mapping and a new evaluation branch that derives century values from extracted year components using libcudf AST operations. New tests validate this against multiple date/datetime dtypes and extreme year offsets.

Changes

Century Extraction Support

Layer / File(s) Summary
Century divisor mapping and validation
python/cudf_polars/cudf_polars/dsl/expressions/datetime.py
Adds _CENTURY_MILLENNIUM_DIVISOR mapping and includes Name.Century in _valid_ops.
Century computation logic
python/cudf_polars/cudf_polars/dsl/expressions/datetime.py
Adds do_evaluate branch extracting YEAR, casting to INT32, and computing ((year - 1) // divisor) + 1 via libcudf AST ops and compute_column.
Century tests
python/cudf_polars/tests/expressions/test_datetime_basic.py
Adds tests for dt.century() across date/datetime dtypes and extreme year-offset edge cases.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • rapidsai/cudf#18443: Both PRs modify the same TemporalFunction class in datetime.py, extending _valid_ops and adding new do_evaluate branches for different temporal operations.

Suggested reviewers: vyasr

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding support for pl.Expr.dt.century.
Description check ✅ Passed The description is related to the change by linking the issue and noting the checklist for the new support.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

@mroeschke

Copy link
Copy Markdown
Contributor Author

/merge

@rapids-bot
rapids-bot Bot merged commit f2fc2aa into NVIDIA:main Jul 8, 2026
132 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in cuDF Python Jul 8, 2026
@mroeschke
mroeschke deleted the cudf_polars/enh/dt_century branch July 8, 2026 20:11
@coderabbitai coderabbitai Bot mentioned this pull request Jul 9, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cudf-polars Issues specific to cudf-polars improvement Improvement / enhancement to an existing function non-breaking Non-breaking change Python Affects Python cuDF API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants